package org.jivesoftware.smackx.snyc.packet;

import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.roster.packet.RosterPacket;
import org.jivesoftware.smack.util.XmlStringBuilder;

public class RosterSubscribeElement implements ExtensionElement {

	public static final String NAMESPACE = "fc:msg:roster";

    public static final String ELEMENT = "subscribe";
	
    private String name = null;

	private RosterItem item = null;

	@Override
	public String getElementName() {
		return ELEMENT;
	}

	@Override
	public String getNamespace() {
		return NAMESPACE;
	}

	@Override
	public CharSequence toXML() {
        XmlStringBuilder xml = new XmlStringBuilder(this);
		xml.attribute("name", name);
		xml.rightAngleBracket();

/*
		XmlStringBuilder itemBuilder = xml.optElement("item", "");
		itemBuilder.attribute("jid", item.getJid());
		itemBuilder.attribute("name", item.getName());
		itemBuilder.rightAngleBracket();
		*/

		xml.append(item.toXML());
        xml.closeElement(this);
        
        return xml;
	}

/*
	protected IQ.IQChildElementXmlStringBuilder getIQChildElementBuilder(IQ.IQChildElementXmlStringBuilder buf) {
		buf.optAttribute("ver", rosterVersion);
		buf.rightAngleBracket();

		synchronized (rosterItems) {
			for (RosterPacket.Item entry : rosterItems) {
				buf.append(entry.toXML());
			}
		}
		return buf;
	}
*/

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public RosterItem getItem() {
		return item;
	}

	public void setItem(RosterItem item) {
		this.item = item;
	}
}
